package com.mmc.dao;

import com.mmc.bean.User;
import com.mmc.sqlSession.SqlSession;
import com.mmc.sqlSession.SqlSessionFactory;
import com.mmc.sqlSession.SqlSessionFactoryBuilder;
import org.dom4j.DocumentException;

import java.beans.IntrospectionException;
import java.beans.PropertyVetoException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

public class UserDaoImpl implements UserDao {

    @Override
    public List<User> queryAll() throws IllegalAccessException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException, DocumentException, PropertyVetoException, ClassNotFoundException {
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder=new SqlSessionFactoryBuilder();
        SqlSessionFactory builder = sqlSessionFactoryBuilder.builder("sqlMapConfig.xml");
        SqlSession sqlSession = builder.openSession();
        List<User> objects = sqlSession.queryAll("User.selectList");
        System.out.println(objects);
        return objects;
    }
}
